//
//  MapViewController.m
//  RoadLine
//
//  Created by dllo on 15/4/24.
//  Copyright (c) 2015年 RedFireNoodles. All rights reserved.
//

#import "MapViewController.h"
#import "Singleton.h"

@interface MapViewController ()

// 地图
@property(nonatomic, retain)MKMapView *mapView;

@end

@implementation MapViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.mapView = [[MKMapView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.location = [NSMutableDictionary dictionary];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.view addSubview:self.mapView];
    // 经纬度
    NSString *lat = self.location[@"lat"];
    NSString *lng = self.location[@"lng"];
    // 坐标
    CLLocationCoordinate2D clLocation = CLLocationCoordinate2DMake([lat doubleValue], [lng doubleValue]);
    // 赋在地图上
    MKCoordinateSpan span = MKCoordinateSpanMake(0.03, 0.03);
    self.mapView.region = MKCoordinateRegionMake(clLocation, span);

    if ([Singleton shareSingleton].isNight) {
        [[Singleton shareSingleton] loadNightModeInfoFormDisk];
    }
}

- (void)setLightDayModel {
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:246/255.0 green:85/255.0 blue:91/255.0 alpha:1];
}

- (void)setNightDayModel {
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:4/255.0 green:165/255.0 blue:171/255.0 alpha:1];
}

- (void)dealloc
{
    [_mapView release];
    [_location release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
